package tiltmaze;

/**
 * This class represents a posintion in a maze.
 * @author Juraj Nižnan
 */
public class RowCol {

    /**
     * a row coordinate
     */
    public int row;

    /**
     * a column coordinate
     */
    public int col;

    /**
     * constructor
     * @param row row coordinate
     * @param col column coordinate
     */
    public RowCol(int row, int col) {
        this.row = row;
        this.col = col;
    }

    /**
     * constructor
     * @param rowcol coordinate
     */
    public RowCol(RowCol rowcol) {
        this.row = rowcol.row;
        this.col = rowcol.col;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final RowCol other = (RowCol) obj;
        if (this.row != other.row) {
            return false;
        }
        if (this.col != other.col) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 1;
        for (int i=0; i<row; i++) {
            hash *= 2;
        }
        for (int i=0; i<col; i++) {
            hash *= 3;
        }
        return hash;
    }

    @Override
    public String toString() {
        return "(" + row + "," + col + ")";
    }

}